<?php
// +----------------------------------------------------------------------------
// | PHP@妖孽 [三十年河东三十年河西,莫欺少年穷.!]
// +----------------------------------------------------------------------------
// | Copyright (c) 2015 http://www.itdaodan.com All rights reserved.
// +----------------------------------------------------------------------------
// | Author: PHP@妖孽 <dino_ma@163.com>
// +----------------------------------------------------------------------------
/**
 *@todo 质检管理
 +------------------------------------------------------------------------------
 * @version   1.0
 * @since 2016-3-3
 +------------------------------------------------------------------------------
 */
namespace Admin\Controller;
class QualityController extends AdminController {
    
	/**
	 * @todo 质检报名查询
	 * @author PHP@妖孽 <mashengjie@hrbjjhh.com>
	 */
	public function querySign(){
		$this->getActivityList();
		$activity_id = (int)I('activity_id');
		$mobile_phone  = (string)I('mobile_phone');
		if($activity_id!=0 && preg_match('/^1[3-8][0-9]{9}$/', $mobile_phone)){
		     $customer_info = D('Admin/Customer')->getCustomerByMobilePhone($mobile_phone,'customer_id');
		     if(!empty($customer_info)){
		         $obj=M('ServiceActivityJoin');
		         $map = array('activity_id'=>$activity_id,'customer_id'=>$customer_info['customer_id']);
                 $ticket_type = $obj->field('ticket_level')->where($map)->find();
                 $ticket_type = $ticket_type['ticket_level'];
                if(false === $ticket_type){
                    $ticket_type = 2;
                    $this->assign('tip_info',$obj->getError());
                }
                $this->assign('ticket_type',$ticket_type);
                
		     }else{
		         $this->error('暂无此用户信息');
		     }
		}
		$this->assign('meta_title','质检报名查询');
		$this->display('querySign');
	}
	
	

	/**
	 * @todo 活动列表
	 * @author PHP@妖孽 <mashengjie@hrbjjhh.com>
	 */
	private function getActivityList(){
	    $activity_list = D('Activity','Service')->getActivityList(0);//活动列表
	    $this->assign('activity_list',$activity_list);
	}
	
	/**
	 * @todo 信息审计
	 * @author PHP@妖孽 <mashengjie@hrbjjhh.com>
	 */
	public function audit(){
	    $mobile_phone  = (string)I('mobile_phone');
	    $list = null;
	    $demand_value  = null;
	    if(preg_match('/^1[3-8][0-9]{9}$/', $mobile_phone)){
	        $customer_info = D('Admin/Customer')->getCustomerByMobilePhone($mobile_phone,'customer_id');
	        if(empty($customer_info)){
	            $this->error('暂无此用户信息');
	        }
	        $customer_id = $customer_info['customer_id'];
	        $service_seat_obj = D('ServiceSeat');
	        $service_api = D('ServiceApi');
	        //用户详细信息
	        $customer_detail =  $service_api->getServiceCustomerDetail($customer_id);
	        if(empty($customer_detail)){
	            $this->error("用户不存在");
	        }
	        $this->assign('customer_detail',$customer_detail);
	        //用户房产信息
	        $house_list=$service_api->getServiceCustomerHouse($customer_id);
	        $this->assign('house_list',$house_list);
	        //装修需求(我的装修需求)
	        $demand_value = $service_seat_obj->getCustomerDemand($customer_id);
	        //用户操作纪录
	        $list=$this->lists('service_operation_log',array('customer_id'=>$customer_id),'operation_log_id desc','member_id,remark,create_time');
	        $this->assign('_list',$list);
	    }
	    $this->assign('demand_value',$demand_value);
	    $this->assign('meta_title','信息审计');
	    $this->display('audit');
	}


	
	
}

